 <{extends file="<{$tempdir}>/member/member.html"}>   
 <{block name=extendjs}>
 <script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/ajaxfileupload.js"> </script>
 <script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/datepicker/WdatePicker.js"> </script>
 <{/block}>
 <{block name=membercenter}> 
 	<div class="mc-right box790"><!--mc-right-->
					<div class="manageBox margin_bottom"><!--manageBox-->
						<div class="title"><!--title-->
							<p class="yleft"><span class="colortip"></span>
							<span class="title_name"><b>订单管理</b></span></p>
						</div><!--title end-->

        <div class="searchTab">
                            <div class="tabTitleWarp clearfix" id="jifen-title">
                               <ul>
											<li class="c"><h3 <{if $actiondo=='order'}> class="addborder"<{/if}>><a  href="<{ofunc type=url link="/order/usersorder"}>">餐厅订单</a></h3></li>
										<li class="c"><h3 <{if $actiondo=='ordermarket'}> class="addborder"<{/if}>><a href="<{ofunc type=url link="/order/usermorder"}>" style="color:#fff;">超市订单</a></h3></li>
										<li class="c"><h3 <{if $actiondo=='usersptorder'}> class="addborder"<{/if}>><a href="<{ofunc type=url link="/order/usersptorder"}>" style="color:#fff;">跑腿订单</a></h3></li>
								 
									</ul>
                            </div>
                            <div class="clear"></div>
         </div>


        <div style="background-color:#fff;border:1px solid #ccc;margin-bottom:10px;">
        	
        	<div class="m3-order-list-search">
										 
										<select class="searchstatus" id="orderdatediff" onchange="getOrders();">
											<option value="0" >当月订单</option>
											<option value="1" <{if $orderdatediff==1}>selected<{/if}>>历史订单</option>
										</select>

											<input type="hidden" id="ordertype" value="0">
										从 	<input type="text" class="searchtime" id="stime" value="<{$stime|date_format:"%Y-%m-%d"}>"  onFocus="WdatePicker({isShowClear:false,readOnly:true});"> 至 
											<input type="text" id="etime" class="searchtime" value="<{$etime|date_format:"%Y-%m-%d"}>"  onFocus="WdatePicker({isShowClear:false,readOnly:true});"> 
										
										<select class="searchstatus" id="orderstatus" onchange="getOrders();">
											<option value="0">订单状态</option>
											<option value="1" <{if $status==1}>selected<{/if}>>处理中</option>
											<option value="2" <{if $status==2}>selected<{/if}>>已完成</option>
										</select>
										
										
										
										
										<input type="image" src="/upload/shop/search.jpg" class="searchs" onclick="getOrders();">
									 
									</div>
        	
        	
        </div>


						<div class="mr-middle content"><!--mr-middle-->
							<div class="user-order m3-user-order"><!-- m3-user-order -->
								 
								 
 
								<div class="order-list m3-order-list"><!-- m3-order-list -->
									

									<div class="m3-order-list-view" id="m3-order-list">
										<table class="di_table">	<tbody>
										<tr>
												<th class="m3-olist1">订单号</th>
											<th class="m3-olist2">联系人</th>
											<th class="m3-olist3">地址</th>
											<th class="m3-olist4">联系电话</th>
											<th class="m3-olist5">下单时间</th>		
											<th class="m3-olist5">需求内容</th>		
											<th class="m3-olist5">订单状态</th>	
											<th class="m3-olist6">完成时间</th>
										</tr>	
										<{if count($list) > 0}>
										<{foreach from=$list item=items}>
										<tr <{if $items['status'] < 4 && $items['posttime'] > $nowtime}> class="noborder"<{/if}>>		
										<td><a href="#orderview" onclick="getOrderDetail(<{$items['id']}>);"><{$items['dno']}></a></td>		
											<td><{$items['buyername']}></td>		
											<td><{$items['buyeraddress']}></td>		
											<td><{$items['buyerphone']}></td>	
											<td><p><{$items['addtime']|date_format:"%Y-%m-%d %H:%M"}></p></td>	
											<td><{$items['content']}></td>	
											<td class="money"><{$buyerstatus[$items['status']]}></td>		<td><{if $items['status'] ==3}> <{$items['suretime']|date_format:"%Y-%m-%d %H:%M"}><{else}>---<{/if}></td>		
												
										</tr>
										<{if $items['status'] < 4 && $items['posttime'] > $nowtime}>
										<tr class="proleng">
											<td colspan="7">
												<div class="progress" pro="1">
													<p class="bg"></p><p class="pro" style="width: 50px;"></p>
											   <ul name="pro_loading">
												<li class="p1  b hover"><span>预定中</span></li>
												<li class="p2  b <{if $items['status'] > 0}>hover<{/if}>""><span>已预订</span></li>
												<li class="p3 s ">
													<a href="javascript:void(0)" style="cursor: default;"><span>取餐中</span></a>
													<a href="javascript:void(0)" style="cursor: default;"></a></li>
												<li class="p4 b <{if $items['status'] > 1}>hover<{/if}>"><span>配送中</span></li>
												<li class="p5 s"><a href="javascript:void(0)" style="cursor: default;"><span>送餐中</span></a></li>
												<li class="p6 b <{if $items['status'] ==3}>hover<{/if}>"><span>已到达</span></li>
											</ul>
										   </div>
										 </td>
										</tr>	
										<{/if}>
										<{/foreach}>
										<{else}>
										<tr>
											<td colspan="7" align="center">
												 暂无数据
											</td>
										</tr>
									  <{/if}>
										</tbody></table>
								   <div class="clear"></div>
								 	   <div class="show_page"> 
								 	   	  <ul>
								 	   	    <{$pagecontent}>
								 	     	</ul>
								 	   </div>
								 		<div class="clear">	</div>
								</div>
								</div>
								
								
								
								
								
								
								
								
								
							</div>
						</div>
						
						
						
		 <div style="background-color:#fff;border:1px solid #ccc;margin-top:10px;display:none;" id="tempordershow">
		 	<a name="orderview" id="orderview"></a>
								<div class="m3-order-detail" id="m3-order-detail">
									
									
								</div>
		 </div>
						
						
						
						
						
						
						
						
						
						
						
						
				</div>
			</div>
<script id="trgoodlist" type="text/html"> 
<div class="m3-order-detail-left">	
										<ul>		
											<li><span>订单编号：</span><^%=order.dno%^></li>		
											<li><span>下单时间：</span><^%=order.addtime%^></li>		
											<li><span>要求时间：</span><^%=order.posttime%^></li>		
											<li><span>完成时间：</span><^%=order.suretime%^></li>		
											<li><span>配送方式：</span><^%if(order.pstype==1){%^>店铺自送<^%}else{%^>平台配送<^%}%^></li>		
												<li><span>支付方式：</span><^%if(order.paytype=='0'){%^>餐到付款<^%}else{%^>在线支付<^%if(order.paystatus=='1'){%^>(已付)<^%}else{%^> (未付) <^%}%^><^%}%^>
												<^%if(order.is_reback=='1'){%^>退款中..<^%}else{%^><^%if(order.is_reback=='2'){%^>退款成功<^%}else{%^><^%}%^><^%}%^>
											</li>		
											<li><span>客户姓名：</span><^%=order.buyername%^></li>		
											<li><span>手机号码：</span><^%=order.buyerphone%^></li>		
											<li><span>配送地址：</span><^%=order.buyeraddress%^></li>		
											<li><span>订单备注：</span><^%=order.excontent%^></li>	
										</ul>	
										<div class="clear"></div>
									</div>
									<div class="m3-order-detail-right">	
										<table>		
											<tbody>
												<tr>			
													<th class="m3-odetail1 ">订单商家：<^%=order.shopname%^></th>			
													<th class="m3-odetail2">订单状态：<^%=order.status%^>   <^%if(order.is_make==1){%^>商家确认制作<^%}else{%^> <^%if(order.is_make==2){%^>商家不制作该订单<^%}else{%^><^%}%^><^%}%^></th>		
												</tr>	
											</tbody>
										</table>	
										<div class="menulist">	
										
											<table>		
												<tbody>
													<^%for(i = 0; i < orderdet.length; i ++) {%^>
													<tr>			
														<td class="m3-odetail1"><^%=orderdet[i].goodsname%^></td>			
														<td class="m3-odetail2">￥<^%=orderdet[i].goodscost%^>*<^%=orderdet[i].goodscount%^></td>			
														<td class="m3-odetail3"><span class="money">￥<^%=orderdet[i].sum%^></span></td>		
													</tr>		
												  <^%}%^> 
					  
												</tbody>
											</table>	
										</div>	
										<table>		
											<tbody>
												<tr>			
													<th class="m3-odetail1">菜单总价：￥<^%=order.goodscost%^></th>			
													<th class="m3-odetail2">配送费：￥<^%=order.pscost%^></th>			
													<th class="m3-odetail3">打包费：￥<^%=order.bagcost%^></th>		
												</tr>	
												<tr>			
													<th class="m3-odetail1">积分抵扣：<^%=order.scoredown%^>个</th>			
													<th class="m3-odetail2">优惠金：<^%=order.yhjcost%^>(券)+<^%=order.cxcost%^>(促销)</th>			
													<th class="m3-odetail3">订单应付：<span class="money">￥<^%=order.allcost%^></span></th>		
												</tr>	
											</tbody>
										</table>
									</div>
							<div class="clear"></div>
</script>
<script type="text/javascript">
	$(document).ready(function(){ 
		for(var i=0;i< $('.proleng').length;i++){
			var whatobj = $('.proleng').eq(i).find('.hover').length;
			whatobj = Number(whatobj)-1;
			var myobj =  $('.proleng').eq(i).find('.hover').eq(whatobj);
			//计算位置
			var cobj = $('.proleng').eq(i).find('.hover').eq(0);
				var menupos =$(myobj).offset();
        var leftend = menupos.left;
        var startpost = $(cobj).offset();
        var leftstart = startpost.left;
        var widths = Number(leftend)-Number(leftstart);
        $('.proleng').eq(i).find('.pro').eq(0).css('width',widths+'px'); 
		} 
	});
	function addAddr()
	{
		$('#newAddr_1').show();
	}
	function getOrderDetail(orderid)
	{  
	        var info = {'orderid':orderid};
	      	var backmes =   ajaxback('<{ofunc type=url link="/order/userorderdet/datatype/json"}>',info); 
	      	if(backmes.flag == false)
	      	{
	      		// $backinfo['order'] = $orderinfo;
		        //$backinfo['orderdet'] = $orderdetinfo;
		         $('#tempordershow').show();
	      		 var htmls = template.render('trgoodlist', {order:backmes.content.order,orderdet:backmes.content.orderdet});
	      	   $('#m3-order-detail').html(htmls); 
	      	}else{
	      		diaerror(backmes.content); 
	      	}  
	}
	function getOrders(){
		//
		var mlinks = '<{ofunc type=url link="/order/usersorder/status/@status@/stime/@stime@/etime/@etime@/orderdatediff/@orderdatediff@"}>';
		mlinks = mlinks.replace('@orderdatediff@', $("#orderdatediff").find("option:selected").val());
		mlinks = mlinks.replace('@status@', $('#orderstatus').find("option:selected").val());
		mlinks = mlinks.replace('@stime@', $('#stime').val());
		mlinks = mlinks.replace('@etime@', $('#etime').val());
	 window.location.href=mlinks;
	}
	function unorder(orderid)
	{
		if(confirm('确定取消订单吗？')){
		   myajax('<{ofunc type=url link="/order/userunorder/datatype/json"}>',{'orderid':orderid});
		}
	}
	function delorder(orderid)
	{
		if(confirm('确定删除订单吗？')){
		   myajax('<{ofunc type=url link="/order/userdelorder/datatype/json"}>',{'orderid':orderid});
		}
	}
	function compelte(orderid)
	{
		window.location.href= siteurl+'/index.php?ctrl=membercenter&action=pingorder&orderid='+orderid;
	}  
</script>
<{/block}>